﻿#region <<版本注释>>
/*---------------------------------------------------------------------
* 项目名称：Http测试
* 项目描述：
* 类 名 称：HttpServer
* 类 描 述：
* 所在的域：DESKTOP-6CB1TV7
* 命名空间：Http测试
* 机器名称：DESKTOP-6CB1TV7
* CLR 版本：4.0.30319.42000
* 作    者：wky
* 创建时间：2021/09/02 15:50:39
* 更新时间：2021/09/02 15:50:39
* 版 本 号:V1.0.0
***********************************************************************
* Copyright @ wky 2021. All rights reserved.
***********************************************************************
//-------------------------------------------------------------------*/
#endregion

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Http测试
{
    public abstract class HttpServer
    {

        protected int port;
        TcpListener listener;
        bool is_active = true;

        public HttpServer(int port) {
            this.port = port;
        }

        public void listen() {

            listener = new TcpListener(port);

            listener.Start();

            while (is_active) {

                TcpClient s = listener.AcceptTcpClient();
                HttpProcessor processor = new HttpProcessor(s,this);
                Thread thread = new Thread(new ThreadStart(processor.process));
                thread.Start();
                Thread.Sleep(1);
            }
        }

        public abstract void handleGETRequest(HttpProcessor p);

        public abstract void handlePOSTRequest(HttpProcessor p, StreamReader inputData);

    }
}
